import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;


public class Bucket implements Comparable<Bucket>{
	private String firstName;
	private String lastName;
	private List<Fish> allFish;
	
	public Bucket(String inFirstName, String inLastName) {
		lastName = inLastName;
		firstName = inFirstName;
		allFish = new ArrayList<>();
	}
	
	public boolean equals(Object what) {
		Bucket other = (Bucket) what;
		
		if( ! lastName.equals(other.lastName)) {
			return false;
		}
		
		if( ! firstName.equals(other.firstName)) {
			return false;
		}
		
		return true;
	}
	
	public void addFish(Fish aFish) {
		allFish.add(aFish);
	}
	
	public String getFirstName() {
		return firstName;
	}
	
	public String getLastName() {
		return lastName;
	}
	
	public Fish getBiggestFish() {
		Fish aFish = Collections.max(allFish);
		return aFish;
	}

	@Override
	public int compareTo(Bucket other) {
		Fish myBiggestFish = getBiggestFish();
		Fish yourBiggestFish = other.getBiggestFish();
		
		int difference = myBiggestFish.compareTo(yourBiggestFish);
		return difference;
	}
	
	public static Comparator<Bucket> byLastNameFirstName() {
		return new Comparator<Bucket> () {

			@Override
			public int compare(Bucket a, Bucket b) {
				int difference = a.lastName.compareTo(b.lastName);
				if(difference != 0) {
					return difference;
				}
				
				difference = a.firstName.compareTo(b.firstName);
				
				return difference;
			}
			
		};
	}
}
